﻿
using Microsoft.EntityFrameworkCore;
using productWebApi.Models;
using System;
using System.Collections.Generic;

namespace ShopeeWebApi.Model;
public class ProductNodeDBContext: DbContext
{  
    public DbSet<UserInfo> UserInfo { get; set; }
    public DbSet<Area> Area { get; set; }
    public DbSet<AreaCategoryRelation> AreaCategoryRelation { get; set; }
    public DbSet<Category> Category { get; set; }
    public DbSet<CategoryAttrRelation> CategoryAttrRelation { get; set; }
    public DbSet<Attribute> Attribute { get; set; }
    public DbSet<AttrValueRelation> AttrValueRelation { get; set; }
    public DbSet<Value> Value { get; set; }

    public DbSet<ErrorDatas> ErrorDatas { get; set; }

    public DbSet<RealShipRaw> RealShipRaw { get; set; }
    public DbSet<RealShip> RealShip { get; set; }
    public DbSet<NodeRaw> NodeRaw { get; set; }
    public DbSet<ProductRaw> ProductRaw { get; set; }

    public DbSet<Node> Node { get; set; }

    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSqlite("Data Source=ProductNode.db");
        //optionsBuilder.LogTo(l=>Console.WriteLine($"sql:{l}"));
    }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        List<Area> areas = new List<Area>()
        {
             new Area(){Id = 1,AreaName = "Singapore",ShorterForm = "SG",Platform=Enum.EnumPlatform.Shopee,ShopId=32531},
             new Area(){Id = 2,AreaName = "Malaysia",ShorterForm = "MY",Platform=Enum.EnumPlatform.Shopee,ShopId=32541},
             new Area(){Id = 3,AreaName = "Thailand",ShorterForm = "TH",Platform=Enum.EnumPlatform.Shopee,ShopId=32539},
             new Area(){Id = 4,AreaName = "Taiwan",ShorterForm = "TW",Platform=Enum.EnumPlatform.Shopee,ShopId=33859},
             new Area(){Id = 5,AreaName = "Indonesia",ShorterForm = "ID",Platform=Enum.EnumPlatform.Shopee,ShopId=33863},
             new Area(){Id = 6,AreaName = "Vietnam",ShorterForm = "VN",Platform=Enum.EnumPlatform.Shopee,ShopId=32543},
             new Area(){Id = 7,AreaName = "Philippines",ShorterForm = "PH",Platform=Enum.EnumPlatform.Shopee,ShopId=32535},
             new Area(){Id = 8,AreaName = "Brazil",ShorterForm = "BR",Platform=Enum.EnumPlatform.Shopee,ShopId=33861},

              new Area(){Id = 9,AreaName = "Australia",ShorterForm = "com.au",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 10,AreaName = "Brazil",ShorterForm = "com.br",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 11,AreaName = "Canada",ShorterForm = "ca",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 12,AreaName = "China(中国大陆)",ShorterForm = "cn",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 13,AreaName = "Egypt",ShorterForm = "eg",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 14,AreaName = "France",ShorterForm = "fr",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 15,AreaName = "Germany(Deutschland)",ShorterForm = "de",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 16,AreaName = "India",ShorterForm = "in",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 17,AreaName = "Italy",ShorterForm = "it",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 18,AreaName = "Japan",ShorterForm = "jp/co.jp",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 19,AreaName = "Mexico",ShorterForm = "com.mx",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 20,AreaName = "Netherlands",ShorterForm = "nl",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 21,AreaName = "Poland",ShorterForm = "pl",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 22,AreaName = "Saudi Arabia",ShorterForm = "sa",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 23,AreaName = "Singapore",ShorterForm = "sg",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 24,AreaName = "Spain",ShorterForm = "es",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 25,AreaName = "Sweden",ShorterForm = "se",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 26,AreaName = "Turkey",ShorterForm = "tr",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 27,AreaName = "United Arab Emirates",ShorterForm = "ae",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 28,AreaName = "United Kingdom",ShorterForm = "co.uk",Platform=Enum.EnumPlatform.Amazon},
              new Area(){Id = 29,AreaName = "United States",ShorterForm = "com",Platform=Enum.EnumPlatform.Amazon},
        };
        modelBuilder.Entity<Area>().HasData(areas.ToArray());
    }
}
